<?php
/**
 * mysql读数据
 * author:oblank
 * date:2011-05-22
 */
include_once( '../drivers/mongo.php' );
include_once( 'config.php' );

$db = $_GET['db'];
$collection = $_GET['table'];	//集和
$concur = $_GET['concur'];	//并发
$total = $_GET['total'];	//数量

if(!$concur || !$total){
	echo "error: set concurrent number or total read number ";
	exit;
}

$fileds = array();
$where = array('nid' => mt_rand(0, 100000));

//db connect
extract($db_mongo);
$dbObj = new myMongo($host, $user, $password);
$dbObj->selectDB($db);
$dbObj->selectCollection($collection);

//start time
list($usec, $sec)  =  explode( " ", microtime() );
$start_time = (float)$usec + (float)$sec;

$data = $dbObj->findAll($fileds, $where);
$current = current($data);
echo $current['id']."\n";

//end time
list($usec, $sec)  =  explode( " ", microtime() );
$end_time = (float)$usec + (float)$sec;

file_put_contents('logs/read_mongo_'.$concur."_".$total."_".$db."_".$collection.'.log', "\n	$start_time	$end_time	".($end_time-$start_time)*10000, FILE_APPEND);
?>